#include<stdio.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#include<stdlib.h>
#include<unistd.h>

int main(int argc,char *argv[])
{
	char buf[100] = {};
	int res = 0;

	if(argc!=3){
		printf("Usage:%s srcpath destpath\n",argv[0]);
		return -1;
	}

	int fdr = open(argv[1],O_RDONLY);
	if(fdr==-1){
		perror("open");
		return -1;
	}
	int fdw = open(argv[2],O_WRONLY|O_CREAT|O_TRUNC,0666);
	if(fdw==-1){
		perror("open");
		return -1;
	}
	
	while((res = read(fdr,buf,100))>0)
		write(fdw,buf,res);
		
	
	close(fdr);
	close(fdw);
	
	return 0;
}